#include "combobox2.h"
#include "ui_combobox2.h"

#include <fstream>
#include <QDebug>

ComboBox2::ComboBox2(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ComboBox2)
{
    ui->setupUi(this);

    // 从文件中读取内容
    std::ifstream ifs("D:/learn/qt-learning/day9/game.txt");
    if (!ifs.is_open())
    {
        qDebug() << "文件打开失败";
        return;
    }
    std::string line;
    while (std::getline(ifs, line))
    {
        ui->comboBox->addItem(QString::fromStdString(line));
    }
    ifs.close();
}

ComboBox2::~ComboBox2()
{
    delete ui;
}
